package com.itheima.homework;

import java.util.Scanner;

/**
 * 评委打分
 */
public class Homework03 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入评委的人数:");
        int num = sc.nextInt();
        int[] score = new int[num];
        System.out.println("请输入各个评委的分数:");
        for (int i = 0; i < score.length; i++) {
            score[i] = sc.nextInt();
        }

        System.out.println("选手的最终得分:" + getScore(num,score));
    }
    public static int getScore(int num,int[] score){
        //score = new int[num];  不应该开辟新的空间 直接把数组传过去就ok了！！
        int max = score[0];
        int min = score[0];
        int sum = 0;
        for(int i = 0; i < score.length; i++){
            sum += score[i];
            if(score[i] > max){
                max = score[i];
            }else if(score[i] < min){
                min = score[i];
            }
        }
        int Score = (sum - min - max) /( score.length - 2);//因为去除了最大值最小值 所以要length - 2！！
        return Score;

    }
}
